package com.suypower.carManage.action;

import javax.servlet.ServletException;

import com.jarp.db.DAO;
import com.opensymphony.xwork2.ActionSupport;
import com.suypower.carManage.comm.ConstUtil;

public class MetadataAction extends ActionSupport{

	private String id;
	private String code;
	private String name;
	private String value;
	
	
	public String execute(){
		DAO dao=new DAO();
		String res="";
		String sql="";
		System.out.println(id);
		if(id!=null&&!id.equals("")){
			sql="UPDATE tb_metadata SET name='"+name+"',value='"+value+"' WHERE id="+id;
		}else{
			sql="INSERT INTO tb_metadata (code,name,value) VALUES ('"+code+"','"+name+"','"+value+"')";
		}
		try {
			int count=dao.execCommand(ConstUtil.DBNAME, sql);
			if(count>0){
				res=this.SUCCESS;
			}else{
				res=this.ERROR;
			}
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return res;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	
	
	
}
